<?php
    session_start();
    include_once '../../../../controlador/php/conexion/Conexion10.php';
    $con = new Conexion10();
    
    $doc = $_REQUEST['documento'];
 
        $select = "SELECT GENPACIEN.OID,PACPRINOM,PACSEGNOM,PACPRIAPE,PACSEGAPE,CAST(DATEDIFF(DD, GENPACIEN.GPAFECNAC, GETDATE()) / 365.25 AS INT) AS EDAD,
                   GDENOMBRE, PACTELEFONO,  GENDETCON.OID as oide
                   FROM GENPACIEN LEFT OUTER JOIN  GENDETCON ON GENPACIEN.GENDETCON = GENDETCON.OID
                                  LEFT OUTER JOIN GENPACIENT ON GENPACIENT.GENPACIEN = GENPACIEN.OID
                   WHERE GENPACIEN.PACNUMDOC = '".$doc."'";
        $resp = $con->query($select);

        while ($resp2 = mssql_fetch_array($resp)){
            $lista[] = array_map(utf8_encode, $resp2);
        }
        print_r(json_encode($lista));

?>
